package com.xiaoge.system.service.impl;

import com.xiaoge.system.entity.Traffic;
import com.xiaoge.system.mapper.TrafficMapper;
import com.xiaoge.system.service.TrafficService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xiaoge
 * @since 2021-04-19
 */
@Service
public class TrafficServiceImpl extends ServiceImpl<TrafficMapper, Traffic> implements TrafficService {

    @Autowired
    public TrafficMapper trafficMapper;
    @Override
    public List<Traffic> getUserNum() {
        Calendar now = Calendar.getInstance();
        System.out.println(now.get(Calendar.DAY_OF_MONTH));
        System.out.println(now.get(Calendar.DATE));
        now.add(Calendar.DATE,-1);
        Date yesterday = now.getTime();
        now.add(Calendar.DATE,-7);
        Date lastServeDay = now.getTime();
        return this.trafficMapper.getUserNum(yesterday,lastServeDay);
    }
}
